<template>
  <a-layout id="components-layout-demo-custom-trigger">
    <a-layout-sider v-model="collapsed" :trigger="null" collapsible>
      <div class="logo" />
    </a-layout-sider>
    <a-layout>
      <a-layout-header style="background: #fff; padding: 0; display:flex; justify-content: space-between">
        <div class="my-layout-header-left">
          <a-icon
              class="trigger"
              :type="collapsed ? 'menu-unfold' : 'menu-fold'"
              @click="() => (collapsed = !collapsed)"
          />
        </div>
        <div class="my-layout-header-right">
          <a-space>
            <div>
              {{this.userInfo.userAccount}}
            </div>
            <div>
              {{ this.userInfo.userName }}
            </div>


            <a-button type="primary" @click="logout">退出</a-button>
          </a-space>

        </div>
      </a-layout-header>
      <a-layout-content
        :style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }"
      >

      </a-layout-content>
      <a-layout-footer style="textAlign: center">
        Ant Design ©2020 Created by HuangShen
      </a-layout-footer>
    </a-layout>
  </a-layout>
</template>
<script>
export default {
  data() {
    return {
      collapsed: false,//是否收起导航栏
      userInfo:{

      }
    };
  },
  mounted() {

    this.$axios({
      method:'get',
      url:'/userInfo',
    }).then(res=>{
      console.log(res)
      this.userInfo=res.data.data
    })
  },
  methods:{
    /**
     * 退出登录
     */
    logout() {
      localStorage.removeItem('Access-Token')
      this.$router.push('/user/login')
    }
  }
};
</script>
<style scoped>
#components-layout-demo-custom-trigger{
  width: 100%;
  height: 100%;
}
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  margin: 16px;
}
</style>
